	.text
main:
	# FUNCTION PROLOGUE
	subu $sp, $sp, 84
	sw $s0, 8($sp)
	sw $ra, 76($sp)
	sw $fp, 80($sp)
	addu $fp, $sp, 84
	# END FUNCTION PROLOGUE

	li $s0, 6
	move $a0, $s0
	# PRE-CALL -> NO REGISTER NEEDS TO BE SAVED
	jal factorial
	move $s0, $v0
	move $a0, $s0
	# PRE-CALL -> NO REGISTER NEEDS TO BE SAVED
	jal printint
	move $s0, $v0
	j L15
L15:
	# FUNCTION EPILOGUE
	lw $fp, 80($sp)
	lw $ra, 76($sp)
	lw $s0, 8($sp)
	addu $sp, $sp, 84
	jr $ra 
	# END FUNCTION EPILOGUE

factorial:
	# FUNCTION PROLOGUE
	subu $sp, $sp, 84
	sw $s0, 8($sp)
	sw $s1, 12($sp)
	sw $ra, 76($sp)
	sw $fp, 80($sp)
	addu $fp, $sp, 84
	# END FUNCTION PROLOGUE

	move $s1, $a0
	beqz $s1, L8
L9:
	li $s0, 0
L10:
	bgtz $s0, L11
L12:
	beq $s1, 1, L2
L3:
	li $s0, 0
L4:
	bgtz $s0, L5
L6:
	sub $s0, $s1, 1
	move $a0, $s0
	# PRE-CALL -> NO REGISTER NEEDS TO BE SAVED
	jal factorial
	move $s0, $v0
	mul $s0, $s1, $s0
L7:
L13:
	move $v0, $s0
	j L14
L8:
	li $s0, 1
	j L10
L11:
	li $s0, 1
	j L13
L2:
	li $s0, 1
	j L4
L5:
	li $s0, 1
	j L7
L14:
	# FUNCTION EPILOGUE
	lw $fp, 80($sp)
	lw $ra, 76($sp)
	lw $s0, 8($sp)
	lw $s1, 12($sp)
	addu $sp, $sp, 84
	jr $ra 
	# END FUNCTION EPILOGUE

